package com.ag.promanagement.dto;

import com.ag.presentation.backEndBeans.UsersView;

import com.ag.promanagement.Users;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class UsersDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String cellNumber;
    private String documentId;
    private String email;
    private String firstName;
    private String lastName;
    private String login;
    private String password;
    private String id_CargoType;
    private String id_DocumentType;
    private String id_UserType;
    private String id;
    private boolean rowSelected = false;
    private UsersView usersView;
    private Users users;

    public Users getUsers() {
        return users;
    }

    public String listener_update(ActionEvent e) {
        try {
            usersView.action_modifyWitDTO(((cellNumber == null) ||
                cellNumber.equals("")) ? null : new Long(cellNumber),
                ((documentId == null) || documentId.equals("")) ? null
                                                                : new Long(
                    documentId),
                ((email == null) || email.equals("")) ? null : new String(email),
                ((firstName == null) || firstName.equals("")) ? null
                                                              : new String(
                    firstName),
                ((id == null) || id.equals("")) ? null : new Long(id),
                ((lastName == null) || lastName.equals("")) ? null
                                                            : new String(
                    lastName),
                ((login == null) || login.equals("")) ? null : new String(login),
                ((password == null) || password.equals("")) ? null
                                                            : new String(
                    password),
                ((id_CargoType == null) || id_CargoType.equals("")) ? null
                                                                    : new Long(
                    id_CargoType),
                ((id_DocumentType == null) || id_DocumentType.equals(""))
                ? null : new Long(id_DocumentType),
                ((id_UserType == null) || id_UserType.equals("")) ? null
                                                                  : new Long(
                    id_UserType));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        id = users.getId().toString();
        cellNumber = (users.getCellNumber() != null)
            ? users.getCellNumber().toString() : null;
        documentId = (users.getDocumentId() != null)
            ? users.getDocumentId().toString() : null;
        email = (users.getEmail() != null) ? users.getEmail().toString() : null;
        firstName = (users.getFirstName() != null)
            ? users.getFirstName().toString() : null;
        lastName = (users.getLastName() != null)
            ? users.getLastName().toString() : null;
        login = (users.getLogin() != null) ? users.getLogin().toString() : null;
        password = (users.getPassword() != null)
            ? users.getPassword().toString() : null;
        id_CargoType = (users.getCargoType().getId() != null)
            ? users.getCargoType().getId().toString() : null;
        id_DocumentType = (users.getDocumentType().getId() != null)
            ? users.getDocumentType().getId().toString() : null;
        id_UserType = (users.getUserType().getId() != null)
            ? users.getUserType().getId().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        id = users.getId().toString();
        cellNumber = (users.getCellNumber() != null)
            ? users.getCellNumber().toString() : null;
        documentId = (users.getDocumentId() != null)
            ? users.getDocumentId().toString() : null;
        email = (users.getEmail() != null) ? users.getEmail().toString() : null;
        firstName = (users.getFirstName() != null)
            ? users.getFirstName().toString() : null;
        lastName = (users.getLastName() != null)
            ? users.getLastName().toString() : null;
        login = (users.getLogin() != null) ? users.getLogin().toString() : null;
        password = (users.getPassword() != null)
            ? users.getPassword().toString() : null;
        id_CargoType = (users.getCargoType().getId() != null)
            ? users.getCargoType().getId().toString() : null;
        id_DocumentType = (users.getDocumentType().getId() != null)
            ? users.getDocumentType().getId().toString() : null;
        id_UserType = (users.getUserType().getId() != null)
            ? users.getUserType().getId().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    public UsersView getUsersView() {
        return usersView;
    }

    public void setUsersView(UsersView usersView) {
        this.usersView = usersView;
    }

    public String getCellNumber() {
        return cellNumber;
    }

    public void setCellNumber(String cellNumber) {
        this.cellNumber = cellNumber;
    }

    public String getDocumentId() {
        return documentId;
    }

    public void setDocumentId(String documentId) {
        this.documentId = documentId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getId_CargoType() {
        return id_CargoType;
    }

    public void setId_CargoType(String id_CargoType) {
        this.id_CargoType = id_CargoType;
    }

    public String getId_DocumentType() {
        return id_DocumentType;
    }

    public void setId_DocumentType(String id_DocumentType) {
        this.id_DocumentType = id_DocumentType;
    }

    public String getId_UserType() {
        return id_UserType;
    }

    public void setId_UserType(String id_UserType) {
        this.id_UserType = id_UserType;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
